<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>settlement</title>
	<link rel="stylesheet" href="__PUBLIC__/style/style.css">
	<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/main.js"></script>
</head>
<body style="background:#F5F5F5;">
	<div class="mask"></div>
	<script type="text/javascript" src="__PUBLIC__/js/requ.js"></script>
	<div class="checkout-header">
		<span></span>
		<h1>确认订单</h1>
		<a href="javascript:;">我的订单</a>
		<ul>
			<a href="javascript:;">464845645</a>
			<li><a href="javascript:;">个人中心</a></li>
			<li><a href="javascript:;">退出登录</a></li>
		</ul>
	</div>
	<div class="settlement-container">
		<h3  id="addAddress">收货地址</h3>

		<foreach name="proord" item="pv">
			<div class="address-cart">
				<span>{$pv.name}</span>
				<p>{$pv.tel}</p>
				<p>{$pv.provinces}，{$pv.city}，{$pv.area}</p>
				<p>{$pv.address}</p>
			</div>
		</foreach>

		<div class="address-add">
			<span>+</span>
			<p>添加新地址</p>
		</div>

			<div class="add-cart">
				<ul>
					<li><input type="text" name="name" id="name" placeholder="姓名"></li>
					<li><input type="text" name="tel" id="tel" placeholder="手机号"></li>
					<li>
						<select id="a" name="provinces">
							<option>省份</option>
						</select>
						<select id="b" name="city">
							<option>地级市</option>
						</select>
						<select id="c" name="area">
							<option>区/县级市</option>
						</select>
					</li>
					<li>
						<input type="text" name="address" id="ajaxAddress" cols="37" rows="4" placeholder="详细地址" />
					</li>
					<li><input type="text" name="zip" id="zip" placeholder="邮政编码"></li>
				</ul>
				<input type="submit" name="submit" value="保存" onclick="ajaxOrder()" />
				<input type="submit" value="取消">
			</div>

		<ul>
			<li><span>支付方式</span><p>在线支付 （支持微信支付、支付宝、银联、财付通、小米钱包等）</p></li>
			<li><span>配送方式</span><p>快递配送（免运费）</p></li>
			<li>
				<table id="address">
					<foreach name="car" item="cv">
						<tr>
							<td><img src="__IMAGE__/{$cv.photourl}{$cv.photoname}" alt="" style="width: 80px;height: 80px"></td>
							<td><p>{$cv.name}&nbsp;&nbsp;&nbsp;{$cv.content}&nbsp;&nbsp;&nbsp;{$cv.color}</p></td>
							<td><span>{$cv.unit}元x{$cv.count}</span></td>
							<td><span>有货</span></td>
							<td><span class="checkout-total">{$cv.price}元</span></td>
						</tr>
					</foreach>

				</table>
			</li>
		</ul>
		<div class="fact-mon">
			<div class="fact-total">
				<ul>
					<li><label>商品件数：</label><span>{$allCount}件</span></li>
					<li><label>金额总计：</label><span>{$allPrice}.00元</span></li>
					<li><label>运费：</label><span>0元</span></li>
					<li><label>应付总额：</label><span>{$allPrice}.00元</span></li>
				</ul>
			</div>
			<input type="submit" value="去结算" onclick="settlement()">
		</div>
	</div>
	<script type="text/javascript" src="__PUBLIC__/js/sjld.js"></script>
	<script type="text/javascript">
			function ajaxOrder(){

				var name = $("#name").val();
				var tel = $("#tel").val();
				var provinces = $("#a").val();
				var city = $("#b").val();
				var area = $("#c").val();
				var address = $("#ajaxAddress").val();
				var zip = $("#zip").val();
				$.ajax({
					type: "POST",
					url: "Home/Product/pro_order?action=ajax",
					dataType: "json",

					data: {"name":name,"tel":tel,"provinces":provinces,"city":city,"area":area,"address":address,"zip":zip},

					beforeSend: function(){
					},
					success: function(json){
						if(json.success==1){
							json.success=0;
							var str = "<div class='address-cart'><span>"+json.name+"</span><p>"+json.tel+"</p><p>"+json.provinces+json.city+json.area+"</p><p>"+json.address+"</p></div>";
							$("#addAddress").after(str);
							validate=false;
						}else{
							alert("AjaxWrong!!");
						}
					}
				})
			}

			function settlement(){
				var active = $('.address-active');
				var judge = active.find('span').text();
				var name = judge;
				var tel = active.find('p').eq(0).text();
				var arr = active.find('p').eq(1).text().split('，');
				var provinces = arr['0'];
				var city = arr['1'];
				var area = arr['2'];
				var address = active.find('p').eq(2).text();
				if(judge==''){
					alert('请先选择地址');
					return 0;
				}

                window.location.replace("Home/Product/settlement");

				// $.ajax({
				// 	type: "POST",
				// 	url: "Home/Product/settlement?action=ajax",
				// 	dataType: "json",
                //
				// 	data: {"name":name,"tel":tel,"provinces":provinces,"city":city,"area":area,"address":address},
                //
				// 	beforeSend: function(){
				// 	},
				// 	success: function(json){
                //
				// 		if(json.success==1){
				// 			json.success=0;
				// 			alert('sduccsss');
				// 			validate=false;
				// 		}else{
				// 			alert("AjaxWrong!!");
				// 		}
				// 	}
				// })
			}
	</script>
</body>
</html>
